<template>
  <el-container>
    <!-- 侧边栏 -->
    <el-aside width="200px">
      <h1 class="logo">黑马头条</h1>
      <!-- 导航条 -->
      <el-menu
      :collapse="isCollapse"
          :default-active="$route.path"
          class="el-menu-vertical-demo"
          background-color="#000"
          text-color="#fff"
          active-text-color="#ffd04b"
          unique-opened
          router
          style="border-right:none"
        >
          <el-menu-item index="/">
          <i class="el-icon-s-grid"></i>
          <span>后台首页</span>
          </el-menu-item>
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span> 文章管理  </span>
            </template>
            <el-menu-item index="/home/post_list">文章列表</el-menu-item>
            <el-menu-item index="/home/post_publish">发布文章</el-menu-item>
          </el-submenu>

          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-circle-plus"></i>
              <span>栏目管理</span>
            </template>
            <el-menu-item index="2-1">栏目列表</el-menu-item>
          </el-submenu>

        </el-menu>
      <!-- 导航条 -->
    </el-aside>
    <el-container>
      <!-- 头部 -->
      <el-header>
        <el-dropdown>
            <!-- <el-radio-button >展开</el-radio-button> -->
          <span class="el-dropdown-link">
            <el-avatar :size="35" src=""></el-avatar>

            <span style="name"> {{ username }}</span>
            <i class="el-icon-arrow-down el-icon--right"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>首页</el-dropdown-item>
            <el-dropdown-item>退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </el-header>
      <el-main><router-view></router-view></el-main>
    </el-container>
  </el-container>
</template>

<script>
import { getID } from "../utils/tokenData.js";
import { userParticulars } from "../apis/user";
export default {
  data() {
    return {
      username: "",
      profileimg: "",
      isCollapse:false,
    };
  },

  async created() {
    const id = getID();
    // console.log(id);
    const res = await userParticulars(id);
    // console.log(res);
    this.username = res.data.data.nickname;
    // this.profileimg = res.data.data.head_img;
  },
};
</script>

<style lang="less" scoped>
.el-header {
  background-color: #333333;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.el-aside {
  background-color: #000000;
  color: rgb(255, 255, 255);
  text-align: center;
  .logo{
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
}

.el-container {
  height: 100vh;
}
.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
  font-size: 20px;
}
.el-icon-arrow-down {
  font-size: 20px;
}
.demonstration {
  display: block;
  color: #8492a6;
  font-size: 14px;
  margin-bottom: 20px;
}

//导航条样式
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 150px;
  min-height: 400px;
}

</style>

